package com.kuanter.adapter;

import java.util.List;

import com.kuanter.kuanterauto.R;
import com.kuanter.kuanterauto.entity.AccountList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
/**
 * 积分列表适配器
 * @author soup
 *
 */
public class Lv_jffromAdapter extends BaseAdapter{
	
	private  List<AccountList> accoutlists=null;
	private Context context;
	
	public Lv_jffromAdapter(Context context,List<AccountList> accoutlists){
		this.accoutlists=accoutlists;
		this.context=context;
	}

	@Override
	public int getCount() {
		return accoutlists.size();
	}

	@Override
	public Object getItem(int position) {
		return accoutlists.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		Holder holder=null;
		if(convertView==null){
			holder=new Holder();
			convertView=LayoutInflater.from(context).inflate(R.layout.lv_jffrom_item, null);
			holder.tv_item_form=(TextView) convertView.findViewById(R.id.tv_item_form);
			holder.tv_item_date=(TextView) convertView.findViewById(R.id.tv_item_date);
			
			convertView.setTag(holder);
		}else{
			holder=(Holder) convertView.getTag();
		}
		String balance=accoutlists.get(position).getBalance();
		String typeName=accoutlists.get(position).getAccountTypeName();
		String groupName=accoutlists.get(position).getCustomerGroupName();
		String time=accoutlists.get(position).getExpireTime();
		
		if(balance!=null&&!balance.equals("")&&typeName!=null&&!typeName.equals("")&&groupName!=null&&!groupName.equals("")){
			holder.tv_item_form.setText(accoutlists.get(position).getBalance()+accoutlists.get(position).getAccountTypeName()+"来自"+accoutlists.get(position).getCustomerGroupName());
		}else{
			holder.tv_item_form.setText("");
		}
		
		if(time!=null&&!time.equals("")){
		holder.tv_item_date.setText(accoutlists.get(position).getExpireTime()+"到期");
		}else{
			holder.tv_item_date.setText("");
		}
		
		
		return convertView;
	}
	
	class Holder{
		TextView tv_item_form;
		TextView tv_item_date;
	}

}
